﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Smart_Archives.Entity
{
    public partial class SaContext : DbContext
    {
        public SaContext()
        {
        }

        public SaContext(DbContextOptions<SaContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Medium> Medium { get; set; }
        public virtual DbSet<SecurityCategoryAndDevice> SecurityCategoryAndDevice { get; set; }
        public virtual DbSet<SecurityDevice> SecurityDevice { get; set; }
        public virtual DbSet<SecurityDeviceCategory> SecurityDeviceCategory { get; set; }
        public virtual DbSet<SecurityDeviceRecord> SecurityDeviceRecord { get; set; }
        public virtual DbSet<User> User { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseMySQL("server=localhost;user id=root;password=000000;database=smart_archives");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");

            modelBuilder.Entity<Medium>(entity =>
            {
                entity.ToTable("medium", "smart_archives");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime).HasColumnName("create_time");

                entity.Property(e => e.LengthOfVideo)
                    .HasColumnName("length_of_video")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.SecurityDeviceId)
                    .HasColumnName("security_device_id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.SecurityDeviceRecordId)
                    .HasColumnName("security_device_record_id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Size)
                    .HasColumnName("size")
                    .HasMaxLength(20)
                    .IsUnicode(false);

                entity.Property(e => e.Type)
                    .HasColumnName("type")
                    .HasColumnType("int(11)");

                entity.Property(e => e.VideoUrl)
                    .HasColumnName("video_url")
                    .HasMaxLength(500)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<SecurityCategoryAndDevice>(entity =>
            {
                entity.ToTable("security_category_and_device", "smart_archives");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime).HasColumnName("create_time");

                entity.Property(e => e.SecurityCategoryId)
                    .HasColumnName("security_category_id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.SecurityDeviceId)
                    .HasColumnName("security_device_id")
                    .HasColumnType("int(11)");
            });

            modelBuilder.Entity<SecurityDevice>(entity =>
            {
                entity.ToTable("security_device", "smart_archives");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ChannelId)
                    .HasColumnName("channel_id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime).HasColumnName("create_time");

                entity.Property(e => e.DeviceModel)
                    .HasColumnName("device_model")
                    .HasMaxLength(200)
                    .IsUnicode(false);

                entity.Property(e => e.DeviceType)
                    .HasColumnName("device_type")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ExtranetIp)
                    .HasColumnName("extranet_ip")
                    .HasMaxLength(30)
                    .IsUnicode(false);

                entity.Property(e => e.ExtranetPort)
                    .HasColumnName("extranet_port")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Factory)
                    .HasColumnName("factory")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.IntranetIp)
                    .HasColumnName("intranet_ip")
                    .HasMaxLength(30)
                    .IsUnicode(false);

                entity.Property(e => e.Location)
                    .HasColumnName("location")
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.LoginName)
                    .HasColumnName("login_name")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Password)
                    .HasColumnName("password")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Port)
                    .HasColumnName("port")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Remarks)
                    .HasColumnName("remarks")
                    .HasMaxLength(200)
                    .IsUnicode(false);

                entity.Property(e => e.Rtsp)
                    .HasColumnName("rtsp")
                    .HasMaxLength(200)
                    .IsUnicode(false);

                entity.Property(e => e.SecurityCategoryId)
                    .HasColumnName("security_category_id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.SerialNumber)
                    .HasColumnName("serial_number")
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Status)
                    .HasColumnName("status")
                    .HasColumnType("int(1)");

                entity.Property(e => e.UpdateTime).HasColumnName("update_time");
            });

            modelBuilder.Entity<SecurityDeviceCategory>(entity =>
            {
                entity.ToTable("security_device_category", "smart_archives");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.ParentId)
                    .HasColumnName("parent_id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Status)
                    .HasColumnName("status")
                    .HasColumnType("int(1)");

                entity.Property(e => e.Type)
                    .HasColumnName("type")
                    .HasColumnType("int(2)");

                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP");
            });

            modelBuilder.Entity<SecurityDeviceRecord>(entity =>
            {
                entity.ToTable("security_device_record", "smart_archives");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime).HasColumnName("create_time");

                entity.Property(e => e.EventAddress)
                    .HasColumnName("event_address")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.EventTime).HasColumnName("event_time");

                entity.Property(e => e.EventType)
                    .HasColumnName("event_type")
                    .HasColumnType("int(2)");

                entity.Property(e => e.GuestIdCard)
                    .HasColumnName("guest_id_card")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.GuestMobile)
                    .HasColumnName("guest_mobile")
                    .HasMaxLength(30)
                    .IsUnicode(false);

                entity.Property(e => e.GuestName)
                    .HasColumnName("guest_name")
                    .HasMaxLength(10)
                    .IsUnicode(false);

                entity.Property(e => e.ImageUrl)
                    .HasColumnName("image_url")
                    .HasMaxLength(255)
                    .IsUnicode(false);

                entity.Property(e => e.SecurityDeviceId)
                    .HasColumnName("security_device_id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.VideoUrl)
                    .HasColumnName("video_url")
                    .HasMaxLength(255)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.ToTable("user", "smart_archives");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime).HasColumnName("create_time");

                entity.Property(e => e.Password)
                    .HasColumnName("password")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Phone)
                    .HasColumnName("phone")
                    .HasMaxLength(20)
                    .IsUnicode(false);

                entity.Property(e => e.Realname)
                    .HasColumnName("realname")
                    .HasMaxLength(20)
                    .IsUnicode(false);

                entity.Property(e => e.Status)
                    .HasColumnName("status")
                    .HasColumnType("int(1)");

                entity.Property(e => e.UpdateTime).HasColumnName("update_time");

                entity.Property(e => e.Username)
                    .HasColumnName("username")
                    .HasMaxLength(50)
                    .IsUnicode(false);
            });
        }
    }
}
